﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections.Specialized;
using System.Data;

using Maticsoft.DBUtility;

public partial class UserControls_blockothers : BaseUserControl 
{
    // Fields
    private NameValueCollection _system = new NameValueCollection();
    protected string Currency;
    protected bool display;
    protected int i = 1;
    protected List<Maticsoft.Model.Team> otherteams = new List<Maticsoft.Model.Team>();
    private SystemConfig sysmodel = new SystemConfig();
    protected Maticsoft.Model.System system = new Maticsoft.Model.System();
    protected Maticsoft.BLL.System systemlist = new Maticsoft.BLL.System();

    // Methods
    public void celanTitle()
    {
        this._system = this.sysmodel.GetSystem();
        if (this._system != null)
        {
            if (this._system["displayTitle"] == "1")
            {
                this.display = true;
            }
            else
            {
                this.display = false;
            }
        }
    }

    public void getCurrency()
    {
        this.system = this.systemlist.GetModel(1);
        if ((this.system != null) && (this.system.Currency != ""))
        {
            this.Currency = this.system.Currency;
        }
        else
        {
            this.Currency = "￥";
        }
    }

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        this.celanTitle();
        this.getCurrency();
    }

    public void UpdateView(int teamid)
    {
        int sideteam = 0;
        if (base.ASSystem != null)
        {
            sideteam = base.ASSystem.Sideteam;
            if (sideteam != 0)
            {
                string str = " 1=1 ";
                int id = 0;
                if (base.CurrentCity != null)
                {
                    id = base.CurrentCity.Id;
                    str = string.Concat(new object[] { str, "  and (City_id=0 or  City_id=", id, ")" });
                }
                else
                {
                    str = str + "  and City_id>=0";
                }
                str = string.Concat(new object[] { str, "  and Team_type='normal' and id<>", teamid, " and Begin_time<='", DateTime.Now.ToString(), "' and end_time>='", DateTime.Now.ToString(), "'" });
                DataTable dt = DbHelperSQL.SelectByFilter("*", "", "", string.Concat(new object[] { "(select top ", sideteam, " * from team where ", str, " order by  sort_order desc,id asc ) as t1" }));
                this.otherteams = new Maticsoft.BLL.Team().DataTableToList(dt);
            }
        }
    }

}